package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.entity.TlBed;
import com.qf.mapper.BedMapper;
import com.qf.service.BedService;
import com.qf.utils.Mycode;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BedServiceImpl extends ServiceImpl<BedMapper, TlBed> implements BedService {
    @Autowired
    BedMapper bedMapper;
    /**
     * 该酒店ID下的所有房型
     * @param hotelId 酒店ID
     * @return list 所有酒店房型
     */
    @Override
    public ResultMsg findHotelItem(Integer hotelId) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("hotel_id",hotelId);
        List list = super.list(queryWrapper);
        if (list==null)
            return ResultMsg.ERROR(Mycode.BEDFIND_ERRO);

        return ResultMsg.SUCCESS(list);
    }

    /**
     *  通过酒店ID下的房型ID 查询对应信息 房型明细
     * @param bedId 房型ID
     * @param hotelId 酒店ID
     * @return
     */
    @Override
    public ResultMsg findBedItem(Integer bedId, Integer hotelId) {
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.eq("bed_id",bedId);
            queryWrapper.eq("hotel_id",hotelId);
        TlBed one = super.getOne(queryWrapper);
        if (one==null)
            return ResultMsg.ERROR(Mycode.BEDFIND_ERRO);
        return ResultMsg.SUCCESS(one);
    }
}
